/**
 * \file
 *           tlmRmtCfgDataInfoSendPara.cpp
 * \brief
 *           Implements tlmRmtCfgDataInfoSendPara class for Telematics services
 *           this is the class of SendPara data infomation of remote configuration.
 *
 * \par Author (last changes):
 *          - Zeng Jie
 *          - BUIC, Continental Automotive Holdings Co., Ltd.
 * \par Project Leader:
 *          -
 * \par Responsible Developer:
 *          - Zeng Jie
 *          - BUIC, Continental Automotive Holdings Co., Ltd.
 * \par Responsible Architect:
 *          - Zhang Fa
 *          - BUIC, Continental Automotive Holdings Co., Ltd.
 *
 * \par Project:
 *      DPCA2
 *
 * \par SW-Component:
 *      Telematics
 *
 * \par SW-Package:
 *      Telematics
 *
 * \par SW-Module:
 *      Telematics Application
 *
* \par SW-Architecture Specification:
 *      DPCA2_TELEMATICS_SW_DD_07a_ready.doc
 *
* \par SW-Design Specification:
 *      DPCA2_TLM-RMTCFG_SW_DD_01d_released.doc
 *
 * \par SW-Test Case Specification:
 *
 * \par CM-Info:
 *
 * \note
 *      This is a note.
 *
 * \bug
 *      - there are no known bugs
 *
 * \par Module-History:
 *
 * \verbatim
 * Date                Author					Reason
 * 10 Dec 2013        Zeng Jie              Initial Creation
 * The latest entry at the head of the history list.
 * \endverbatim
 *
 * \par Copyright Notice:
 * Copyright (C) 2012 Continental Automotive Holdings Co., Ltd.
 * Alle Rechte vorbehalten. All Rights Reserved.\n
 * The reproduction, transmission or use of this document or its contents is
 * not permitted without express written authority.\n
 * Offenders will be liable for damages. All rights, including rights created
 * by patent grant or registration of a utility model or design, are reserved.
 *
 */

#include "stdafx.h"
#include "tlmRmtCfgDataInfoSendPara.h"
//## attribute mParaAdmin
#include "tlmRmtCfgParaAdmin.h"
//## attribute mParaNavi
#include "tlmRmtCfgParaNavi.h"
//## attribute mParaWeb
#include "tlmRmtCfgParaWeb.h"

#include "tlmRmtCfgSrvApp.h"

#include "teleLogTrace.h"

/**
* \brief tlmRmtCfgDataInfoSendPara: this is constructor of tlmRmtCfgDataInfoSendPara class
*
* \note
*
* \param[in]
* - bufptr: pointer to buffer that store the datainfo message
*   size  : size of the datainfo buffer
*
* \return
* - none
*/
tlmRmtCfgDataInfoSendPara::tlmRmtCfgDataInfoSendPara(uint8_t* bufPtr, uint32_t size) :tlmRmtCfgDataInfo(bufPtr, size), mParaAdmin(NIL), mParaNavi(NIL), mParaWeb(NIL)  {
    //#[ operation tlmRmtCfgDataInfoSendPara(uint8_t*,uint32_t)
    //#]
}

/**
* \brief tlmRmtCfgDataInfoSendPara: this is default constructor of tlmRmtCfgDataInfoSendPara class
*
* \note
*
* \param[in]
* - none
*
* \return
* - none
*/
tlmRmtCfgDataInfoSendPara::tlmRmtCfgDataInfoSendPara() :tlmRmtCfgDataInfo(), mParaAdmin(NIL), mParaNavi(NIL), mParaWeb(NIL) {
}

/**
* \brief ~tlmRmtCfgDataInfoSendPara: this is destructor of tlmRmtCfgDataInfoSendPara class 
*
* \note
*
* \param[in]
* - none
*
* \return
* - none
*/
tlmRmtCfgDataInfoSendPara::~tlmRmtCfgDataInfoSendPara() {
}

/**
* \brief Fill : fill the data info of send para(31) message.
*               Use the para object to fill the buffer,
*
* \note
*
* \param[in]
* - none
*
* \return
* - none
*
* [Covers: MRN_TLM-RMTCFG_SW_DD_039]
*/
void tlmRmtCfgDataInfoSendPara::Fill() {
    //#[ operation Fill()
    
    //before use Fill(), we must set the dataInfobuffer     
    
    //Init the dataInfo Msg 
                                 
    
    mDataInfoBuffer.reset();     
    
    //the first byte should be 0x7E
    mDataInfoBuffer.setValue(SEPERATE_LEVEL_1); 
    
    //set parameters
    //next is 0x10  
    mDataInfoBuffer.setValue(TLM_RMT_CFG_DATA_INFO_CODE_CONFIGURATION);   
                                             
    //the seperator shall be set in the Fill Function    
    if(mParaWeb!=NIL)
    {
    	mParaWeb->SetMsgBuf(&mDataInfoBuffer);
    	mParaWeb->Fill();  
    }
    
    if(mParaNavi!=NIL)
    {     
    	mParaNavi->SetMsgBuf(&mDataInfoBuffer);
    	mParaNavi->Fill();   
    }
           
    if(mParaAdmin!=NIL)
    {          
    	mParaAdmin->SetMsgBuf(&mDataInfoBuffer);
    	mParaAdmin->Fill(); 
    }                      
    
    
    //set the datainfo size
    mDataInfoSize = mDataInfoBuffer.getSize();
              
    
    //#]
}

/**
* \brief GetMaxDataInfoSize: Get the max length of data info of send para message.
*
* \note
*
* \param[in]
* - none
*
* \return
* -  uint32_t : the max data info size
*
*/
uint32_t tlmRmtCfgDataInfoSendPara::GetMaxDataInfoSize() {
    //#[ operation GetMaxDataInfoSize()
    return TLM_RMT_CFG_DATA_INFO_SEND_PARA_MAX_SIZE;
    //#]
}

/**
* \brief Init: Init the data info of send para(31) message, just set the para object point.
*
* \note
*
* \param[in]
* - none
*
* \return
* - none
*
* [Covers: MRN_TLM-RMTCFG_SW_DD_038]
*/
void tlmRmtCfgDataInfoSendPara::Init() {
    //#[ operation Init()
    //tlmRmtCfgSrvApp * pRmtCfgSrvApp = reinterpret_cast<tlmRmtCfgSrvApp *>(mItsService);
    tlmRmtCfgSrvApp * pRmtCfgSrvApp = reinterpret_cast<tlmRmtCfgSrvApp *>(tlmRmtCfgSrvApp::GetInstance());
    
    
    if (pRmtCfgSrvApp != NIL)
    {
    	mParaWeb = pRmtCfgSrvApp->GetParaWeb(); 
    	mParaNavi = pRmtCfgSrvApp->GetParaNavi();      
    	mParaAdmin = pRmtCfgSrvApp->GetParaAdmin();
    }
    else
    {
        LOG_PRINT(DPCA_TELE_MAIN_ERROR,"[TLM_MSGSRV]:<tlmRmtCfgSrvApp::%s> srvApp is NIL\n", __FUNCTION__);
    }
    
    //#]
}
